package com.lepu.app.fun.mother_circle.bean;

import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.lepu.app.fun.my.bean.BeanPubContentImage;

public class BeanMotherTopic {


    public String topicID;
    public String topicAvatar;
    public String topicUserId;
    public String topicUserName;
    public String topicTime;  //创建时间
    public String topicReplyTime; //回复时间
    public String topicUpdateTime; //更新时间
    public String topicCommentCount;
    public String topicLookCount;
    public String topicLikeCount;
    
    public String topicTitle;
    public String topicContent;
    public String topicContentImage;
    
    public ArrayList<BeanPubContentImage> MediaList;  //图片list
    
    public int topicIsLike;
    public int topicIsTop;
    public int topicIsGood;//是否精华 0-否，1-是
    public int topicIsHot;//
    
    public static ArrayList<BeanMotherTopic> parseJsonData(String dataString) {
    	ArrayList<BeanMotherTopic> topicList = new ArrayList<BeanMotherTopic>();
        try {
            JSONObject jsonObject = new JSONObject(dataString);
            JSONObject obj1 = (JSONObject) jsonObject.get("Result");
            JSONArray dataArray = obj1.getJSONArray("ListInfo");

            for(int i=0; i<dataArray.length(); i++){
				JSONObject focusJson = (JSONObject) dataArray.get(i);
				BeanMotherTopic motherTopic = new BeanMotherTopic();
				motherTopic.topicID = focusJson.optString("TopicID");
				motherTopic.topicAvatar = focusJson.optString("UserAvatar");
				motherTopic.topicUserId = focusJson.optString("UserID");
				motherTopic.topicUserName = focusJson.optString("UserNickName");
				motherTopic.topicTime = focusJson.optString("RecordCreateTime");
				motherTopic.topicReplyTime = focusJson.optString("LatestReplyTime");
				motherTopic.topicUpdateTime = focusJson.optString("RecordUpdateTime");
				motherTopic.topicCommentCount = focusJson.optString("ReplyCount");
				motherTopic.topicLookCount = focusJson.optString("ViewCount");
				motherTopic.topicLikeCount = focusJson.optString("FavourCount");
				motherTopic.topicTitle = focusJson.optString("TopicTitle");
				motherTopic.topicContent = focusJson.optString("TopicDetail");
				motherTopic.topicContentImage = focusJson.optString("TopicDescription");
				motherTopic.topicIsTop = focusJson.optInt("IsTop");
				motherTopic.topicIsLike = focusJson.optInt("HasFavour");
				motherTopic.topicIsGood = focusJson.optInt("IsGood");
				motherTopic.topicIsHot = focusJson.optInt("IsHot");
				
				ArrayList<BeanPubContentImage> imageList = new ArrayList<BeanPubContentImage>();
				JSONArray imageArray = focusJson.getJSONArray("MediaList");
				for(int k=0; k<imageArray.length(); k++){
					JSONObject imageJson = (JSONObject) imageArray.get(k);
					BeanPubContentImage image = new BeanPubContentImage();
					image.MediaID = imageJson.optString("MediaID");
					image.MediaType = imageJson.optString("MediaType");
					image.MediaUri = imageJson.optString("MediaUri");
					image.Width = imageJson.optString("Width");
					image.Height = imageJson.optString("Height");
					imageList.add(image);
				}
				
				motherTopic.MediaList = imageList;
				
				topicList.add(motherTopic);
			}
        } catch (JSONException e) {
            e.printStackTrace();
        }
        
        return topicList;
    }

    //刷新时间
    public static String parseJsonDate(String dataString) {
    	String date = "";
        try {
            JSONObject jsonObject = new JSONObject(dataString);
            JSONObject obj1 = (JSONObject) jsonObject.get("Result");
            JSONObject objDetail = obj1.getJSONObject("DetailInfo");
            date = objDetail.getString("RefreshTime");

        } catch (JSONException e) {
            e.printStackTrace();
        }
        
        return date;
    }
    
    public static ArrayList<BeanMotherTopic> getTestDataType1(){
    	ArrayList<BeanMotherTopic>  list = new ArrayList<BeanMotherTopic>();
    	
    	BeanMotherTopic bean1 = new BeanMotherTopic();
    	bean1.topicUserName = "乐普医疗";
    	bean1.topicTime = "10分钟前";
    	bean1.topicCommentCount = "99";
    	bean1.topicLookCount = "999";
    	bean1.topicTitle = "乐普医疗的新产品";
    	bean1.topicContent = "乐普医疗的新产品有哪些优点呢,欲知后事如何，请听下回分解，啦啦啦啦啦啦啦啦啦阿拉拉拉";
    	BeanMotherTopic bean2 = new BeanMotherTopic();
    	bean2.topicUserName = "乐普医疗";
    	bean2.topicTime = "10分钟前";
    	bean2.topicCommentCount = "99";
    	bean2.topicLookCount = "999";
    	bean2.topicTitle = "乐普医疗的新产品";
    	bean2.topicContent = "乐普医疗的新产品有哪些优点呢,欲知后事如何，请听下回分解，啦啦啦啦啦啦啦啦啦阿拉拉拉";
    	BeanMotherTopic bean3 = new BeanMotherTopic();
    	bean3.topicUserName = "乐普医疗";
    	bean3.topicTime = "10分钟前";
    	bean3.topicCommentCount = "99";
    	bean3.topicLookCount = "999";
    	bean3.topicTitle = "乐普医疗的新产品";
    	bean3.topicContent = "乐普医疗的新产品有哪些优点呢,欲知后事如何，请听下回分解，啦啦啦啦啦啦啦啦啦阿拉拉拉";
    	
    	list.add(bean1);
    	list.add(bean2);
    	list.add(bean3);
    	
        return list;
    }
    
}
